package com.gitee.feizns.explore.data_structure.tree.bs.easy;

import java.util.LinkedList;
import java.util.List;

/**
 * @author feizns
 * @since 2019/12/9
 */
public class InOrderTraversal {

    public static List<Integer> inorderTraversal(TreeNode root) {
        return inorderTraversal(new LinkedList<>(), root);
    }

    private static List<Integer> inorderTraversal(List<Integer> ret, TreeNode root) {
        if ( root != null ) {
            inorderTraversal(ret, root.left);
            ret.add(root.val);
            inorderTraversal(ret, root.right);
        }
        return ret;
    }

}
